<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Demo3-1-7</title>
<script type="text/javascript" src="xmlDom.js"></script>
<script type="text/javascript">
window.onload = function() {
	//获得HTML的message节点
	var divNode = document.getElementById("message");
	
	//加载XML文档
	var xmlDoc = loadXML("./message.xml");
	
	//解析XML，在HTML中输出每条数据
	var msgNodes = xmlDoc.getElementsByTagName('email');
	var newNode = "<table border='1'>";
	for (var i=0; i<msgNodes.length; i++){
		//获得节点值
		var to = msgNodes[i].getElementsByTagName("to")[0].firstChild.nodeValue;
		var from = msgNodes[i].getElementsByTagName("from")[0].firstChild.nodeValue;
		var title = msgNodes[i].getElementsByTagName("title")[0].firstChild.nodeValue;
		var sendTime = msgNodes[i].getElementsByTagName("sendTime")[0].firstChild.nodeValue;
		//创建新的节点
		newNode += "<tr>";
		newNode += "<td>"+to+"</td><td>"+from+"</td><td>"+title+"</td><td>"+sendTime+"</td>"
		newNode += "</tr>";
	}
	newNode += "</table>";
	divNode.innerHTML = newNode;
}
</script>
</head>
<body>
<div id="header"></div>
<div id="main">
	<div id="message"></div>
</div>
<div id="footer"></div>
</body>
</html>